set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode='nonstrict';
set hive.exec.max.dynamic.partitions=400;
set hive.exec.max.dynamic.partitions.pernode=400;

insert overwrite table jms_dm.dm_route_whole_push_jdw_dt
select
     in_from_code
    ,in_from_name
    ,out_to_code
    ,out_to_name
    ,effect_type
    ,taking_times
    ,dt
from (
    select  in_from_code
        ,in_from_name
        ,out_to_code
        ,out_to_name
        ,search_type as effect_type
        ,latest_warehousing_time_quantum as taking_times
        ,dt
        ,row_number() over(partition by in_from_code,out_to_code,latest_warehousing_time_quantum order by search_type) as rn
    from jms_dm.dm_route_whole_node_base_dt
    where dt = '{{ execution_date | cst_ds }}'
) a where a.rn = 1
distribute by pmod(hash(rand()), 100);